import pytest
from common.request_util_test import RequestUtil
from common.test_yaml_util_test import YamlUtil
from config import datas
import json

class Testnode:

    @pytest.mark.parametrize('nodeinfo', YamlUtil().read_testcase_yaml('v24.06/resourcemanage/node/1_get_node_list.yaml'))
    def test_get_node_list(self, nodeinfo, get_env_info):
        # 获取node列表接口
        baseUrl = get_env_info
        url = baseUrl + nodeinfo['request']['url']
        method = nodeinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == nodeinfo['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('nodeinfo', YamlUtil().read_testcase_yaml('v24.06/resourcemanage/node/2_get_specific_node.yaml'))
    def test_get_specific_node(self, nodeinfo, get_env_info):
        # 获取指定的node
        baseUrl = get_env_info
        url = baseUrl + nodeinfo['request']['url'].replace('{nodename}',datas.hostname)
        method = nodeinfo['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == nodeinfo['validate'][0]['equals']['status_code']

